package cn.hh.nacos;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
public class MyConfig {

    //配置负载均衡实现RestTemplate
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

    //使用随机分发算法
    //参考https://gitee.com/butalways1121/SpringCloudFeign-Ribbon
    //https://blog.csdn.net/qq_40036754/article/details/101627337
    /*@Bean
    public IRule getRule(){
        return new RandomRule();
    }*/

}
